function xh=vech(x,pos)
nr=size(x,1); 
if ~isequal(size(x),nr*ones(1,2))
    error('x must be a square matrix') 
end 
if nargin==1 
    pos=find( tril(ones(nr))==1 );
else 
    if length(pos(:))~=0.5*nr*(nr+1)
        error('POS must be nr*(nr+1) and has wrong dimension') 
    end 
end 
xh=x(pos); 
    
